# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Maintainer: Orhun Parmaksız <orhun@archlinux.org>

pkgname=cargo-tarpaulin
pkgver=0.27.1
pkgrel=1
_tag=ba971a1dd04b961b7454c653fa1b2595dbee96af
pkgdesc='Tool to analyse test coverage of cargo projects'
arch=(loong64 x86_64)
url=https://github.com/xd009642/tarpaulin
license=(Apache MIT)
depends=(
  gcc-libs
  glibc
  libcurl.so
  openssl
  libssh2
  libgit2
  zlib
)
makedepends=(
  git
  rust
)
source=(git+https://github.com/xd009642/tarpaulin.git#tag=${_tag})
b2sums=('SKIP')

prepare() {
  cargo fetch \
    --locked \
    --target $CARCH-unknown-linux-gnu \
    --manifest-path tarpaulin/Cargo.toml
}

pkgver() {
  cd tarpaulin
  git describe --tags
}

build() {
  export CARGO_TARGET_DIR=target
  export LIBSSH2_SYS_USE_PKG_CONFIG=1
  CFLAGS+=" -ffat-lto-objects"
  cargo build \
    --release \
    --frozen \
    --manifest-path tarpaulin/Cargo.toml
}

package() {
  cd tarpaulin
  install -Dm 755 "${srcdir}/target/release/${pkgname}" -t "${pkgdir}"/usr/bin/
  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE-MIT -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
